<%@page import="helpers.UrlHelper"%>
<%@page import="entities.CheckSpeed"%>
<%@page import="java.util.TreeMap"%>
<%
TreeMap check = (TreeMap) request.getAttribute("check");
String name = (String) request.getAttribute("name");
CheckSpeed checkSpeed = (CheckSpeed) request.getAttribute("checkSpeed");

//Set content for seo
String title = UrlHelper.getDomainServer(request) + " - Check Speed";
String description = "Test your Internet connection bandwidth to locations around the world with this interactive broadband speed test. Provice free tool website free test and your results will provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks.";
String keywords = "speed test, check speed, broadband speed, internet connection speed, upload speed, download speed";
String ogimage = UrlHelper.getServerUrl(request) + "/images/sitepage.png";
String url = UrlHelper.getServerUrl(request);

if (name != null && !name.isEmpty()) {
	description = name + " - Result speed test website ";
	keywords = name + ", www." + name + ", " + keywords ;
	ogimage = "http://chart.apis.google.com/chart?chs=80x80&cht=qr&chld=|0&chl=http://" + name;
	url = UrlHelper.getServerUrl(request)  + "/check-speed?domain=" + name;
}
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/layouts/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
    <jsp:param name="description" value="<%=description %>" />
    <jsp:param name="keywords" value="<%=keywords %>" />
    <jsp:param name="ogtitle" value="<%=title %>" />
    <jsp:param name="ogurl" value="<%=url %>" />
    <jsp:param name="ogimage" value="<%=ogimage %>" />
    <jsp:param name="ogdescription" value="<%=description%>" />
</jsp:include>

	<script type="text/javascript" src="/js/check_speed.js"></script>
	<script type="text/javascript">
		var name = "<%=name%>";
		var url = "<%=UrlHelper.getServerUrl(request)%>";
	</script>
                <div id="leftSideContent">
                	<section class="block">
                    	<div class="blockContent" id="checkspeed">
                            <h3 class="blockHeading"><span><%=checkSpeed != null ? checkSpeed.getDomain() : "Check Speed" %></span></h3>
                            <div class="clearafter">
                            	<div class="form-input">
                            		<p class="topIntro">
	                                	Test your Internet connection bandwidth to locations around the world with this interactive broadband speed test. Provice free tool website free test and your results will provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks.
	                                </p>
	                            	<h3 class="title">Enter a domain name:</h3>
	                                <form class="searchDomain" action="" method="get">
	                                    <div class="gridLayout gridLayout2 clearafter">
	                                        <div class="gridCol">                                            
	                                            <label>
	                                                <input type="text" value="<%=name != null ? name : "" %>" size="25" name="domain">
	                                                <% if (check.get("name") != null) { %>
	                                                	<span class="error">(<%=check.get("name") %>)</span>
	                                                <% } %>
	                                            </label>                                            
	                                        </div>
	                                        <div class="gridCol lastCol">
	                                            <button type="submit" class="buttonStyle">Check speed</button>
	                                        </div>
	                                    </div>
	                                </form>
	                            </div>
	                            
                                <% if (checkSpeed != null && checkSpeed.isProcessing()) { %>
                                <script type="text/javascript" src="/js/process_check_speed.js"></script>
                                
                                <h3 class="title">Processing...</h3>  
                                <br />  
                                <div class="processDomain">
	                            	<ul class="hormenu anchor">
						                 <li>
						                 	<a rel="1" isdone="1" class="selected" href="#wiz1step1">
						                     	<span class="h2">WAITING</span>
						                         <span class="dot"><span></span></span>
						                         <span class="label">Sending Request</span>
						                     </a>
						                 </li>
						                 <li>
						                 	<a rel="2" isdone="0" class="" href="#wiz1step2">
						                     	<span class="h2">GET DATA</span>
						                         <span class="dot"><span></span></span>
						                         <span class="label">Process Request</span>
						                     </a>
						                 </li>
						                 <li>
						                 	<a rel="3" isdone="0" class="" href="#wiz1step3">
						                     	<span class="h2">DONE</span>
						                         <span class="dot"><span></span></span>
						                         <span class="label">Finished</span>
						                     </a>
						                 </li>
						             </ul>
						             
						             <div class="msg">
						             	<h3>Process analysis data will take a few minutes.</h3>
						             	<img src="/images/loading.gif">
						             	<div>
						             		<script type="text/javascript"><!--
											google_ad_client = "ca-pub-2883566427648799";
											/* epufloor_468x60 */
											google_ad_slot = "4163244680";
											google_ad_width = 468;
											google_ad_height = 60;
											//-->
											</script>
											<script type="text/javascript"
											src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
											</script>
						             	</div>
						             </div>
	                        	 </div>
                                <% } %>
                                
                                <% if (checkSpeed != null && !checkSpeed.isProcessing()) { %>
                                <div class="gridLayout summary-result clearafter">
                                	<div class="gridCol lastCol">
                                		<div class="gridCol_inner">
                                			<h3 class="title">Summary</h3>
                                			<br />
                                			<div class="content-center">
							             		<script type="text/javascript"><!--
												google_ad_client = "ca-pub-2883566427648799";
												/* epufloor_468x60 */
												google_ad_slot = "4163244680";
												google_ad_width = 468;
												google_ad_height = 60;
												//-->
												</script>
												<script type="text/javascript"
												src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
												</script>
							             	</div>
							             	<br />
		                                	<%=checkSpeed.getTableResult() %>
			    	
									    	<table cellspacing="0" cellpadding="20" border="1" align="center" class="pretty result" id="table1">
								                <tbody>
								                <tr>
								                    <th valign="middle" align="center" class="empty"></th>
								                    <th valign="middle" align="center">First View</th>
								                    <th valign="middle" align="center">Repeat View</th>                </tr>
								                <tr>
								                    <td valign="middle" align="left">Waterfall</td>
								                    <td valign="middle" align="center"><img width="250" src="<%=checkSpeed.getWaterfallThumb()%>" class="progress"></td>
								                    <td valign="middle" align="center"><img width="250" src="<%=checkSpeed.getWaterfallCachedThumb() %>" class="progress"></td>
								                </tr>
									    		</tbody>
									    	</table>
									    </div>
									</div>
                                </div>
                                
                                <div class="gridLayout content-breakdown clearafter">
                                	<div class="gridCol lastCol">
                                		<div class="gridCol_inner">
                                			<h3 class="title">Content Breakdown</h3>
                                			<br />
                                			<div class="content-center">
							             		<script type="text/javascript"><!--
												google_ad_client = "ca-pub-2883566427648799";
												/* epufloor_468x60 */
												google_ad_slot = "4163244680";
												google_ad_width = 468;
												google_ad_height = 60;
												//-->
												</script>
												<script type="text/javascript"
												src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
												</script>
							             	</div>
							             	<br />
                                			<!--Load the AJAX API-->
										    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
										    <script type="text/javascript">
											<%=checkSpeed.getContentBreakdown() %>
											</script>
											
											<table align="center">
										        <tr>
										            <th colspan="2">
										            <h2>Content breakdown by MIME type (First  View)</h2>
										            </th>
										        </tr>
										        <tr>
										            <td>
										                <div id="pieRequestsFv_div" style="width:300px; height:300px;"></div>
										            </td>
										            <td>
										                <div id="pieBytesFv_div" style="width:300px; height:300px;"></div>
										            </td>
										        </tr>
										        <tr>
										            <td>
										                <div id="tableRequestsFv_div" style="width: 100%;"></div>
										            </td>
										            <td>
										                <div id="tableBytesFv_div" style="width: 100%;"></div>
										            </td>
										        </tr>
										    </table>
										    
										    <hr />
										    <h2>Connection View</h2>
										    <img src="<%=checkSpeed.getConnectionView() %>">
										    <br />
										    
										    <hr />
										    <table align="center">
										        <tr>
										            <th colspan="2">
										            <h2>Content breakdown by MIME type (Repeat  View)</h2>
										            </th>
										        </tr>
										        <tr>
										            <td>
										                <div id="pieRequestsRv_div" style="width:300px; height:300px;"></div>
										            </td>
										            <td>
										                <div id="pieBytesRv_div" style="width:300px; height:300px;"></div>
										            </td>
										        </tr>
										        <tr>
										            <td>
										                <div id="tableRequestsRv_div" style="width: 100%;"></div>
										            </td>
										            <td>
										                <div id="tableBytesRv_div" style="width: 100%;"></div>
										            </td>
										        </tr>
										    </table>
											
											<hr />
											
											<h2>Connection View (Repeat View)</h2>
										    <img src="<%=checkSpeed.getConnectionViewRp()%>">
										    <br /> 
                                			
                                		</div>
                                	</div>
                                </div>
                                <% } %>
                            </div>
                        </div>
                        <div class="blockShadow"></div>
                    </section>                	
                </div>
                
                <!-- right content -->
                <jsp:include page="/elements/right.jsp" />
                <!-- end right content -->
                
<jsp:include page="/layouts/footer.jsp" />